qinglan.Canvas.Initialize = qinglan.Canvas.Class(function() {}).statics({
	initModule: function() {
		//Provides requestAnimationFrame in a cross browser way.
		qinglan.Canvas.requestAnimationFrame = window.requestAnimationFrame = (function() {
			return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame ||
			function( /* function FrameRequestCallback */ callback, /* DOMElement Element */ element) {
				window.setTimeout(callback, 1000 / qinglan.Canvas.Config.frames);
			};
		})();

		//initMainFsm
		var mainFsm = new qinglan.Canvas.Fsm('main', qinglan.Canvas.World.fsmManager);
		var init = new qinglan.Canvas.State('init', mainFsm);
		var resourceLoad = new qinglan.Canvas.State('resourceLoad', mainFsm);
		var mainMenu = new qinglan.Canvas.State('mainMenu', mainFsm);
		var modeSelect = new qinglan.Canvas.State('modeSelect', mainFsm);
		var paly = new qinglan.Canvas.State('play', mainFsm);
		var over = new qinglan.Canvas.State('over', mainFsm);

		mainFsm.addStates([init, resourceLoad, mainMenu, modeSelect, paly, over]);
		qinglan.Canvas.World.fsmManager.addFsm(mainFsm);


		//initMainLayer
		var mianLayer = new qinglan.Canvas.Layer('main', 1);
		qinglan.Canvas.World.frm.addLayer(mianLayer);

		//debugLayer
		var fps = new qinglan.Canvas.FPS('gameFps', null, {
			color: new qinglan.Canvas.Color(1, 0, 0, .5),
			size: 20,
			textAlign: 'center'
		});
		var debugLayer = new qinglan.Canvas.Layer('debug', 100);
		debugLayer.addSprite(fps);
		qinglan.Canvas.World.frm.addLayer(debugLayer);
	}
});

qinglan.Canvas.Initialize.initModule();
